package com.esirong.whatime.ui.adpater;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.esirong.dao.Task;
import com.esirong.whatime.R;

import java.util.List;

/**
 * 任务列表适配器
 * Created by esirong on 2015/11/7.
 */
public class TaskAdapter extends AdapterBase<Task> {

    public TaskAdapter(Context context, List<Task> list) {
        super(context, list);
    }

    @Override
    protected View getExView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = View.inflate(parent.getContext(), R.layout.item_task, null);
            holder.timestamp = (TextView) convertView.findViewById(R.id.task_timestamp);
            holder.avatar = (ImageView) convertView.findViewById(R.id.task_avatar);
            holder.title = (TextView) convertView.findViewById(R.id.task_title);
            holder.note = (TextView) convertView.findViewById(R.id.task_note);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        Task item = getList().get(position);
        holder.title.setText(item.getTitle());
        holder.note.setText(item.getNote());
        holder.note.setText("转换日期"+item.getStart_at());
        return convertView;
    }

    private static class ViewHolder {
        ImageView avatar;
        TextView title;
        TextView note;
        TextView timestamp;
    }

    @Override
    protected void onReachBottom() {

    }
}
